﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TV_Channel
{
    class Program
    {
        static void Main(string[] args)
        {
            //Channel channel = new Channel("Pervyi", 1);
            //Channel channelTwo = new Channel("Vtoroy", 2);
            //Channel channelThree = new Channel("Tretiy", 3);
            //Channel channelFour = new Channel("Chetvertyi", 4);
            //Channel channelFive = new Channel("Pyatyi", 5);

            TV television = new TV();
            television.GenerateListOfchannels();
            television.ShowCurrentChannel();
            Console.ReadLine();

            television.SwitchChannelDown();
            television.ShowCurrentChannel();
            Console.ReadLine();

            television.SwitchChannelUp();
            television.ShowCurrentChannel();
            Console.ReadLine();

            television.SwitchChannelUp();
            television.ShowCurrentChannel();
            Console.ReadLine();

            television.SwitchChannelUp();
            television.ShowCurrentChannel();
            Console.ReadLine();

            television.SwitchChannelDown();
            television.ShowCurrentChannel();
            Console.ReadLine();
        }
    }

    class Channel
    {
      public int channelNumber;
        public string channelName;

        public Channel(string name, int number)
        {
            this.channelName = name;
            this.channelNumber = number;
        }

        public int number
        {
            get
            {
                return number;
            }
            set
            {
                channelNumber = value;
            }
        }

        public string name
        {
            get
            {
                return name;
            }
            set
            {
                channelName = value;
            }
        }
    }

    class TV
    {
        private List<Channel> channelList;
        public int currentChannel { get; set; }
        public void GenerateListOfchannels()
        {
            channelList = new List<Channel>();
            Channel channel = new Channel("Pervyi", 1);
            channelList.Add(channel);
            Channel channelTwo = new Channel("Vtoroy", 2);
            channelList.Add(channelTwo);    
            Channel channelThree = new Channel("Tretiy", 3);
            channelList.Add(channelThree);
            Channel channelFour = new Channel("Chetvertyi", 4);
            channelList.Add(channelFour);
            Channel channelFive = new Channel("Pyatyi", 5);
            channelList.Add(channelFive);
            currentChannel = 0;
        }

        public void SwitchChannelUp()
        {
            for (int i = 0; i < channelList.Count - 1; i++)
            {
                if (currentChannel == 0)
                {
                    currentChannel = channelList.Count - 1;
                }
                else
                {
                  currentChannel--;              
                }
            }
        }


        public void SwitchChannelDown ()
        {
            for (int i = 0; i < channelList.Count-1; i++)
            {
                if (currentChannel == channelList.Count-1)
                {
                  currentChannel = 0;
                }
                else
                {
                    currentChannel++;
                }
            }
        }

        public void ShowCurrentChannel()
        {
            Console.WriteLine("Текущий канал : {0}, {1}", channelList[currentChannel].channelNumber, channelList[currentChannel].channelName);
        }
    }
}
